import { INCREASE, REDUCTION } from './cartActionTypes';

let defaultState = {
    num: 0
}
export default (state = defaultState, action) => {
    console.log(action);
    //增加
    if (action.type === INCREASE) {
        let initState = JSON.parse(JSON.stringify(state));
        initState.num++;
        return initState;
    }
    //減少
    if (action.type === REDUCTION) {
        let initState = JSON.parse(JSON.stringify(state));
        initState.num--;
        return initState;
    }
    return state
}
